package com.goodmr.passport.webapp.controller;

import com.goodmr.passport.webapp.model.request.SigninSocialReq;
import com.goodmr.passport.webapp.model.response.SigninResp;
import com.goodmr.passport.webapp.model.response.SocialAuthUrlResp;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 社交平台登录
 *
 * @author <a href="mailto:bingdong13@msn.com">bigo</a>
 */
@RestController
@RequestMapping(path = "/passport")
public class SocialController {

    /**
     * 获取社交平台登录授权URL
     *
     * @param redirectUri 登录授权URL
     * @return String
     */
    @GetMapping("/{platform}/authorize")
    public ResponseEntity<SocialAuthUrlResp> authUrl(@PathVariable String platform,
                                                     @RequestParam("redirect_uri") String redirectUri) {
        return null;
    }

    /**
     * 社交平台登录
     *
     * @param body 登录请求数据包
     * @return 登录成功返回 token，否则返回异常
     */
    @PostMapping("/{platform}/signin")
    public ResponseEntity<SigninResp> login(@PathVariable String platform,
                                            @Valid @RequestBody SigninSocialReq body) {
        return null;
    }
}
